// pages/zhuren/zhuren.js
import * as echarts from '../../ec-canvas/echarts' // 这个是自己实际的目录

var barec1 = null;
var barec2 = null;
var barec3 = null;
var barec4 = null;
var barec5 = null;

let app=getApp();

// 就业质量
function initChart1(canvas, width, height, dpr) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height,
    devicePixelRatio: dpr // new
  });
  canvas.setChart(chart);
 
  var option = {
    title: {
      text: '就业质量',
      left: '5%'
    },
    color: ['#5087ec', '#85d0dc', '#58a55c'],
    legend: {
      data: ['前端开发', '短视频运营', '大数据'],
      top: 50,
      left: 'center',
      z: 100
    },
    grid: {
      containLabel: true,
      top: '100'
    },
    tooltip: {
      show: true,
      trigger: 'axis'
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['C2109班'],
      // show: false
    },
    yAxis: {
      x: 'center',
      type: 'value',
      splitLine: {
        lineStyle: {
          type: 'solid'
        }
      }
      // show: false
    },
    series: [{
      name: '前端开发',
      type: 'bar',
      smooth: true,
      data: [20],
      barGap:0
    }, {
      name: '短视频运营',
      type: 'bar',
      smooth: true,
      data: [15]
    }, {
      name: '大数据',
      type: 'bar',
      smooth: true,
      data: [30]
    }]
  };
 
  chart.setOption(option);
  return chart;
}


//就业率
function initChart2(canvas, width, height, dpr) {
  const chart = echarts.init(canvas, null, {
     width: width,
     height: height,
     devicePixelRatio: dpr // new
   });
   canvas.setChart(chart);
 
   var option = {
     title: {
       text: '就业率',
       left: '5%'
     },
     tooltip: {
       trigger: 'axis',
       axisPointer: {            // 坐标轴指示器，坐标轴触发有效
         type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
       },
       confine: true
     },
     legend: {
       data: []
     },
     grid: {
       left: 20,
       right: 20,
       bottom: 15,
       top: 40,
       containLabel: true
     },
     xAxis: [
       {
         type: 'value',
         axisLine: {
           lineStyle: {
             color: '#999'
           }
         },
         axisLabel: {
           color: '#666'
         }
       }
     ],
     yAxis: [
       {
         type: 'category',
         axisTick: { show: false },
         data: ['前端', '短视频', '大数据', '全栈', '测试', '人工智能'],
         axisLine: {
           lineStyle: {
             color: '#999'
           }
         },
         axisLabel: {
           color: '#666'
         }
       }
     ],
     series: [
       {
         name: '热度',
         type: 'bar',
         label: {
           normal: {
             show: true,
             position: 'inside'
           }
         },
         data: [300, 270, 340, 344, 300, 320, 310],
         itemStyle: {
           // emphasis: {
           //   color: '#37a2da'
           // }
         }
       }
      
     ]
   };
 
   chart.setOption(option);
   return chart;
 }
 
 //面试量
 function initChart3(canvas, width, height, dpr) {
   const chart = echarts.init(canvas, null, {
     width: width,
     height: height,
     devicePixelRatio: dpr // new
   });
   canvas.setChart(chart);
  
   var option = {
     title: {
       text: '面试量',
       left: '5%'
     },
     color: ['#5087ec', '#85d0dc'],
     legend: {
       data: ['前端', '短视频','大数据','全栈'],
       top: 50,
       left: 'center',
       z: 100
     },
     grid: {
       containLabel: true,
       top: '100'
     },
     tooltip: {
       show: true,
       trigger: 'axis'
     },
     xAxis: {
       type: 'category',
       boundaryGap: false,
       data: ['周一','周二','周三','周四','周五'],
       // show: false
     },
     yAxis: {
       x: 'center',
       type: 'value',
       splitLine: {
         lineStyle: {
           type: 'solid'
         }
       }
       // show: false
     },
     series: [{
       name: '前端',
       type: 'line',
       smooth: false,
       data: [10,20,30,55,70]
     }, {
       name: '短视频',
       type: 'line',
       smooth: false,
       data: [15,22,50,70,80]
     }, {
       name: '大数据',
       type: 'line',
       smooth: false,
       data: [15,22,50,70,80]
     }, {
       name: '全栈',
       type: 'line',
       smooth: false,
       data: [15,22,50,70,80]
     }]
   };
  
   chart.setOption(option);
   return chart;
 }
 
 //环比
 function initChart4(canvas, width, height, dpr) {
   const chart = echarts.init(canvas, null, {
     width: width,
     height: height,
     devicePixelRatio: dpr // new
   });
   canvas.setChart(chart);
  
   var option = {
     title: {
       text: '环比',
       left: '5%'
     },
     color: ['#5087ec', '#85d0dc'],
     legend: {
       data: ['上周', '本周'],
       top: 50,
       left: 'center',
       z: 100
     },
     grid: {
       containLabel: true,
       top: '100'
     },
     tooltip: {
       show: true,
       trigger: 'axis'
     },
     xAxis: {
       type: 'category',
       boundaryGap: false,
       data: ['周一','周二','周三','周四','周五'],
       // show: false
     },
     yAxis: {
       x: 'center',
       type: 'value',
       splitLine: {
         lineStyle: {
           type: 'solid'
         }
       }
       // show: false
     },
     series: [{
       name: '上周',
       type: 'line',
       smooth: false,
       data: [10,20,30,55,70]
     }, {
       name: '本周',
       type: 'line',
       smooth: false,
       data: [15,22,50,70,80]
     }]
   };
  
   chart.setOption(option);
   return chart;
 }
 
 //毕业人数
 function initChart5(canvas, width, height, dpr) {
   const chart = echarts.init(canvas, null, {
     width: width,
     height: height,
     devicePixelRatio: dpr // new
   });
   canvas.setChart(chart);
  
   var option = {
     title: {
       text: '毕业人数',
       left: '5%'
     },
     color: ['#5087ec', '#85d0dc', '#58a55c'],
     legend: {
       data: ['C2109A班', 'C2109B班', 'C2109C班'],
       top: 50,
       left: 'center',
       z: 100
     },
     grid: {
       containLabel: true,
       top: '100'
     },
     tooltip: {
       show: true,
       trigger: 'axis'
     },
     xAxis: {
       type: 'category',
       boundaryGap: false,
       data: ['C2109班'],
       // show: false
     },
     yAxis: {
       x: 'center',
       type: 'value',
       splitLine: {
         lineStyle: {
           type: 'solid'
         }
       }
       // show: false
     },
     series: [{
       name: 'C2109A班',
       type: 'bar',
       smooth: true,
       data: [20],
       barGap:0
     }, {
       name: 'C2109B班',
       type: 'bar',
       smooth: true,
       data: [15]
     }, {
       name: 'C2109C班',
       type: 'bar',
       smooth: true,
       data: [30]
     }]
   };
  
   chart.setOption(option);
   return chart;
 }

Page({

  /**
   * 页面的初始数据
   */
  data: {
    data:{},
    touSuData:{},
    qishu:[],
    index:"0",
    list:{
      xingming:'宋云星',
      zhiwu:'校长',
      bumen:'管理部门'
    },
    value: "2",
    option: [
      { text: '当期', value: '1' },
      { text: '2108', value: '2' },
      { text: '2107', value: 'c' },
      { text: '2106', value: 'd' },
      { text: '2105', value: 'e' },
      { text: '2104', value: 'f' },
      { text: '半年内', value: 'g' },
      { text: '一年内', value: 'h' }
    ],
    ec1: {
      onInit: function (canvas, width, height, dpr) {
        barec1 = echarts.init(canvas, null, {
          width: width,
          height: height,
          devicePixelRatio: dpr // new
        });
        canvas.setChart(barec1);
        return barec1;
      }
    },
    ec2: {
      onInit: function (canvas, width, height, dpr) {
        barec2 = echarts.init(canvas, null, {
          width: width,
          height: height,
          devicePixelRatio: dpr // new
        });
        canvas.setChart(barec2);
        return barec2;
      }
    },
    ec3: {
      onInit: function (canvas, width, height, dpr) {
        barec3 = echarts.init(canvas, null, {
          width: width,
          height: height,
          devicePixelRatio: dpr // new
        });
        canvas.setChart(barec3);
        return barec3;
      }
    },
    ec4: {
      onInit: function (canvas, width, height, dpr) {
        barec4 = echarts.init(canvas, null, {
          width: width,
          height: height,
          devicePixelRatio: dpr // new
        });
        canvas.setChart(barec4);
        return barec4;
      }
    },
    ec5: {
      onInit: function (canvas, width, height, dpr) {
        barec5 = echarts.init(canvas, null, {
          width: width,
          height: height,
          devicePixelRatio: dpr // new
        });
        canvas.setChart(barec5);
        return barec5;
      }
    }
  },
  switchTab(e){
      this.setData({
        index: e.currentTarget.dataset['index']
      })
  },
  zhuanye(){
    wx.navigateTo({
      url: '/pages/xiaoZhangZhuanYeZhiDa/xiaoZhangZhuanYeZhiDa'
    })
  },
  tousu(){
    wx.navigateTo({
      url: '/pages/zhrtslxxx/zhrtslxxx'
    })
  },
  onClickLeft() {
  },
  onClickRight() {
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    app.http.suoYouQiShu({}).then(res=>{
      console.log("qishu:",res.data.data)
      // this.setData({
      //   qishu: res.data.data
      // });
      this.qishu = [{text:"当期",value:"a"}];
      var self = this;
      res.data.data.forEach(function(item){
        self.qishu.push({
          text:item.name,
          value:item.name
        })
      })
      this.qishu.push({
        text:"半年内",
        value:"b"
      },{
        text:"一年内",
        value:"c"
      })
      console.log("123",this.qishu)
    })
    app.http.xiaoZhangShouYe({type:"2205"}).then(res=>{
      this.setData({
        data: res.data.data
      });
      this.getInitChart1();
      this.getInitChart2();
      this.getInitChart3();
      this.getInitChart4();
      this.getInitChart5();
    })
    app.http.xiaoZhangTouSuLiXiang({role:"0"}).then(res=>{
      this.setData({
        touSuData: res.data.data
      });
    })
  },
  // 就业质量
  getInitChart1(){
    var zhuanyeArr = [];
    var series = [];
    this.data.data.collegeEmploymentRateList.forEach(item=>{
      zhuanyeArr.push(item.cname);
      series.push({
        name: item.cname,
        type: 'bar',
        smooth: true,
        data: [item.money]
      })
    })
    barec1.setOption({
      title: {
        text: '就业质量',
        left: '5%'
      },
      color: ['#5087ec', '#85d0dc', '#58a55c'],
      legend: {
        data: zhuanyeArr,
        top: 50,
        left: 'center',
        z: 100
      },
      grid: {
        containLabel: true,
        top: '100'
      },
      tooltip: {
        show: true,
        trigger: 'axis'
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['C2109班'],
        // show: false
      },
      yAxis: {
        x: 'center',
        type: 'value',
        splitLine: {
          lineStyle: {
            type: 'solid'
          }
        }
        // show: false
      },
      series: series
    });
  },
  // 就业率
  getInitChart2(){
    var zhuanyeArr = [];
    this.data.data.collegeEmploymentRateList.forEach(item=>{
      zhuanyeArr.push(item.cname)
    })
    barec2.setOption({
      title: {
        text: '就业率',
        left: '5%'
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
          type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        },
        confine: true
      },
      legend: {
        data: []
      },
      grid: {
        left: 0,
        right: 40,
        bottom: 15,
        top: 40,
        containLabel: true
      },
      xAxis: [
        {
          type: 'value',
          axisLine: {
            lineStyle: {
              color: '#999'
            }
          },
          axisLabel: {
            color: '#666'
          }
        }
      ],
      yAxis: [
        {
          type: 'category',
          axisTick: { show: false },
          data: zhuanyeArr,
          axisLine: {
            lineStyle: {
              color: '#999'
            }
          },
          axisLabel: {
            color: '#666'
          }
        }
      ],
      series: [
        {
          name: '热度',
          type: 'bar',
          label: {
            normal: {
              show: true,
              position: 'inside'
            }
          },
          data: [300, 270, 340, 344, 300, 320, 310],
          itemStyle: {
            // emphasis: {
            //   color: '#37a2da'
            // }
          }
        }
       
      ]
    })
  },
  // 面试量
  getInitChart3(){
    var zhuanyeArr = [];
    var series = [];
    this.data.data.interviewList.forEach(item=>{
      zhuanyeArr.push(item.cname);
      series.push({
        name: item.cname,
        type: 'bar',
        smooth: true,
        data: [parseInt(item.money)]
      })
    })
    barec3.setOption({
      title: {
        text: '面试量',
        left: '5%'
      },
      color: ['#5087ec', '#85d0dc'],
      legend: {
        data: ['前端', '短视频','大数据','全栈'],
        top: 50,
        left: 'center',
        z: 100
      },
      grid: {
        containLabel: true,
        top: '100'
      },
      tooltip: {
        show: true,
        trigger: 'axis'
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['周一','周二','周三','周四','周五'],
        // show: false
      },
      yAxis: {
        x: 'center',
        type: 'value',
        splitLine: {
          lineStyle: {
            type: 'solid'
          }
        }
        // show: false
      },
      series: [{
        name: '前端',
        type: 'line',
        smooth: false,
        data: [10,20,30,55,70]
      }, {
        name: '短视频',
        type: 'line',
        smooth: false,
        data: [15,22,50,70,80]
      }, {
        name: '大数据',
        type: 'line',
        smooth: false,
        data: [15,22,50,70,80]
      }, {
        name: '全栈',
        type: 'line',
        smooth: false,
        data: [15,22,50,70,80]
      }]
    });
  },
  // 环比
  getInitChart4(){
    var zhuanyeArr = [];
    var series = [];
    this.data.data.weekToWeekList.forEach(item=>{
      zhuanyeArr.push(item.cname);
      series.push({
        name: item.cname,
        type: 'bar',
        smooth: true,
        data: [parseInt(item.money)]
      })
    })
    barec4.setOption({
      title: {
        text: '环比',
        left: '5%'
      },
      color: ['#5087ec', '#85d0dc'],
      legend: {
        data: ['上周', '本周'],
        top: 50,
        left: 'center',
        z: 100
      },
      grid: {
        containLabel: true,
        top: '100'
      },
      tooltip: {
        show: true,
        trigger: 'axis'
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['周一','周二','周三','周四','周五'],
        // show: false
      },
      yAxis: {
        x: 'center',
        type: 'value',
        splitLine: {
          lineStyle: {
            type: 'solid'
          }
        }
        // show: false
      },
      series: [{
        name: '上周',
        type: 'line',
        smooth: false,
        data: [10,20,30,55,70]
      }, {
        name: '本周',
        type: 'line',
        smooth: false,
        data: [15,22,50,70,80]
      }]
    });
  },
   // 毕业人数
   getInitChart5(){
    var zhuanyeArr = [];
    var series = [];
    this.data.data.collegeEmploymentRateList.forEach(item=>{
      zhuanyeArr.push(item.c_name);
      series.push({
        name: item.c_name,
        type: 'bar',
        smooth: true,
        data: [item.total],
        barGap:0
      })
    })
    barec5.setOption({
      title: {
        // text: '毕业人数',
        left: '5%'
      },
      color: ['#5087ec', '#85d0dc', '#58a55c'],
      legend: {
        data:zhuanyeArr,
        top: 50,
        left: 'center',
        z: 100
      },
      grid: {
        containLabel: true,
        top: '100'
      },
      tooltip: {
        show: true,
        trigger: 'axis'
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['C2109班'],
        // show: false
      },
      yAxis: {
        x: 'center',
        type: 'value',
        splitLine: {
          lineStyle: {
            type: 'solid'
          }
        }
        // show: false
      },
      series: series
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})